home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / git-4.3 / git-4 / git-4.3.7 / src / gitaction < prev    next >
Encoding:
Text File  |  1995-07-16  |  6.6 KB  |  141 lines

  1. #!/bin/sh
  2.  
  3. ###############################################################################
  4. #                                                                             #
  5. #           GNU Interactive Tools 4.3.7 per file type action script           #
  6. #                               Global version                                #
  7. #               Copyright (C) 1994 Free Software Foundation, Inc.             #
  8. #                   Written by Tudor Hulubei and Andrei Pitis.                #
  9. #                          Enhanced by Verdoolaege Sven.                      #
  10. #                                                                             #
  11. ###############################################################################
  12.  
  13. #
  14. # This script executes a different action for each file type specified.
  15. # The script tries to match (using gitmatch) the second parameter against
  16. # the patterns given as command line arguments to gitmatch (see below).
  17. # gitmatch returns 0 if the parameter doesn't match or the number in the
  18. # list of the pattern that matched.
  19. # If you want to add new file types & actions to this script, just add a
  20. # new pattern after the last pattern in the list and a corresponding
  21. # action to the 'case' statement.
  22. #
  23. # For grater flexibility, gitaction's first parameter is the name of the
  24. # directory where the file resides. So, you can get the complete file
  25. # name appending the file base name to the file path just like that: $1/$2
  26. #
  27. # If you enhance this script, please send me a patch (tudor@chang.pub.ro).
  28. # I'll include it in the next release.
  29. #
  30.  
  31. #
  32. # The original patch sent by Verdoolaege Sven had 'less' instead of more.
  33. # I don't know if all Unix systems have 'less', but I am pretty sure they
  34. # have 'more', so I've put 'more' back, for the sake of portability.
  35. # If I am wrong, please email me.  Anyway, if you really want 'less', feel
  36. # free to change :-)
  37. #
  38. # NEW!!!
  39. #   Instead of hardcoding "more" or "less" here, we can now use GIT_PAGER, a
  40. # shell environment variable that binds on one of them, depending on your
  41. # environment.  The default is to call "more", but if you change your
  42. # GIT_PAGER environment variable, you will hopefully use "less" or any pager
  43. # you like.
  44. #
  45.  
  46. name=`basename $0`
  47.  
  48. if test "$#" -ne 2 -o ! -d "$1" -o ! -f "$2"; then
  49.     echo "$name: GIT internal script" >&2
  50.     exit 255
  51. fi
  52.  
  53. type=0
  54.  
  55. if test -f .gitaction; then
  56.     ./.gitaction $1 $2
  57.     type=$?
  58. fi
  59.  
  60. if test $type != 0; then
  61.     exit 0
  62. fi
  63.  
  64. gitmatch $2 "*.cc" "*.c" "*.l" "*.y" "*.h" "*.s" "*.S" "*.o" "*.a" "*.sa"   \
  65.             "Makefile" "makefile"                                           \
  66.             "*.tar.gz" "*.tgz" "*.tar.z" "*.tar.Z" "*.taz" "*.tar" "*.gz"   \
  67.             "*.z" "*.Z"                                                     \
  68.             "*.zip" "*.arj" "*.rar"                                         \
  69.             "*.texi" "*.texinfo" "*.man"                                    \
  70.             "*.doc" "*.txt" "*.lsm"                                         \
  71.             "*.gif" "*.jpg" "*.jpeg" "*.tif" "*.bmp"                        \
  72.             "*.mpg"                                                         \
  73.             "*.mod" "*.s3m" "*.voc" "*.wav"                                 \
  74.             "*.ps" "*.dvi" "*.tex"                                          \
  75.         "*.[1-9n]" "*.[1-9n][xXm]"                        \
  76.         "*.[1-9n].[zZ]" "*.[1-9n][xXm].[zZ]"                 \
  77.         "*.[1-9n].gz" "*.[1-9n][xXm].gz"                    \
  78.             "*.fli" "*.flc"                            \
  79.         "*.pgp" "*.asc"
  80.  
  81. type=$?
  82.  
  83. case $type in
  84. 0)              $GIT_PAGER $2;;                         # no match
  85. 1)              c++ -O2 $2;;                            # *.cc
  86. 2)              cc  -O2 $2;;                            # *.c
  87. 3)              lex     $2;;                            # *.l
  88. 4)              yacc -d $2;;                            # *.y
  89. 5)              $GIT_PAGER $2;;                         # *.h
  90. 6  | 7)         cc      $2;;                            # *.s, *.S
  91. 8)              objdump -hnrt $2 | $GIT_PAGER;;         # *.o
  92. 9  | 10)        ar -tv        $2 | $GIT_PAGER;;         # *.a, *.sa
  93. 11 | 12)        make;;                                  # Makefile, makefile
  94. 13 | 14)        (echo "Compressed file info:";          # *.tar.gz      \
  95.                 gunzip -l  $2;                          # *.tgz         \
  96.                 echo;                                                   \
  97.                 echo "Tar file info:";                                  \
  98.                 gunzip -c  $2 | tar tvf - ) | $GIT_PAGER;;
  99. 15 | 16 | 17)   (echo "Compressed file info:";          # *.tar.z       \
  100.                 gunzip -l  $2;                          # *.tar.Z       \
  101.                 echo;                                   # *.taz         \
  102.                 echo "Tar file info:";                                  \
  103.                 gunzip -c  $2 | tar tvf - ) | $GIT_PAGER;;
  104. 18)             tar tvf    $2 | $GIT_PAGER;;            # *.tar
  105. 19)             gunzip -c  $2 | $GIT_PAGER;;            # *.gz
  106. 20 | 21)        uncompress -c  $2 | $GIT_PAGER;;        # *.z, *.Z
  107. 22)             unzip -v   $2 | $GIT_PAGER;;            # *.zip
  108. 23)             unarj l    $2 | $GIT_PAGER;;            # *.arj
  109. 24)             unrar l    $2 | $GIT_PAGER;;            # *.rar
  110. 25 | 26)        makeinfo   $2;;                         # *.texi, *.texinfo
  111. 27)             nroff -man $2 | $GIT_PAGER;;            # *.man
  112. 28 | 29 | 30)   $GIT_PAGER $2;;                         # *.doc, *.txt
  113. 31 | 32 | 33)   zgv        $2;;                         # *.gif, *.jpg, *.jpeg
  114. 34)                                                     # *.tif         \
  115.                 echo;                                                   \
  116.                 echo "No *.tif viewer specified.";                      \
  117.                 echo "Please edit the gitaction script.";;
  118. 35)                                                     # *.bmp         \
  119.                 echo;                                                   \
  120.                 echo "No *.bmp viewer specified.";                      \
  121.                 echo "Please edit the gitaction script.";;
  122. 36)             if [ $DISPLAY ]; then mpeg_play $2; 
  123.                                  else mpeg_vga $2;fi;;  # *.mpg
  124. 37 | 38)        s3mod $2 &;;                            # *.mod *.s3m
  125. 39 | 40)        vplay $2 &;;                            # *.voc
  126. 41)             if [ $DISPLAY ]; then (ghostview $2 &);fi;;     # *.ps
  127. 42)             if [ $DISPLAY ]; then (xdvi $2 &);fi;;          # *.dvi 
  128. 43)             latex $2;;
  129. 44 | 45)    nroff -man $2 | $GIT_PAGER;;
  130. 46 | 47 | 48 | 49)
  131.         gunzip -c $2 | nroff -man | $GIT_PAGER;;
  132. 50 | 51)    flip $2;;
  133. 52 | 53)    pgp $2;;
  134.                 
  135. esac
  136.  
  137. echo
  138. echo "Press any key ..."
  139.  
  140. exit 0
  141.